const TOKEN_KEY = 'APP_TOKEN'

// base
export function getItem(key) {
  const val = localStorage.getItem(key)
  return JSON.parse(val)
}

export function setItem(key, val) {
  if (!val) return
  return localStorage.setItem(key, JSON.stringify(val))
}

export function removeItem(key) {
  return localStorage.removeItem(key)
}

export function clearAll() {
  return localStorage.clear()
}

// end base

export function getToken() {
  return getItem(TOKEN_KEY)
}

export function setToken(token) {
  return setItem(TOKEN_KEY, token)
}

export function removeToken() {
  return removeItem(TOKEN_KEY)
}
